﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TasksUI.Controls
{
    public partial class TaskControllerControl : UserControl
    {
        public TaskControllerControl()
        {
            InitializeComponent();
        }

        [DefaultValue(null)]
        public TaskListControl TaskList { get; set; }

        [DefaultValue(null)]
        public TasksModel.TaskLibrary Library { get; set; }

        [DefaultValue("")]
        public string Title
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return lblTitle.Text; }
            [System.Diagnostics.DebuggerStepThrough]
            set { lblTitle.Text = value; }
        }

        private TasksModel.TaskClass _class;

        [DefaultValue(null)]
        public TasksModel.TaskClass Class
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return _class; }
            set
            {
                _class = value;
                switch (_class)
                {
                    case TasksModel.TaskClass.ImportantUrgent:
                        BackColor = Color.OrangeRed;
                        break;
                    case TasksModel.TaskClass.ImportantNotUrgent:
                        BackColor = Color.MediumPurple;
                        break;
                    case TasksModel.TaskClass.UnimportantUrgent:
                        BackColor = Color.Orange;
                        break;
                    case TasksModel.TaskClass.UnimportantNotUrgent:
                        BackColor = Color.Azure;
                        break;
                }
            }
        }

        private void tsbNew_Click(object sender, EventArgs e)
        {
            TasksModel.Task t = TaskDetails.AddNewTask(ParentForm, Library, Class);
            if (t != null)
            {
                TaskList.TaskList.Append(t);
            }
        }
    }
}
